load("@npm//@angular/dev-infra-private/benchmark/component_benchmark:component_benchmark.bzl", "component_benchmark")
load("//tools:defaults.bzl", "ng_test_library", "ng_web_test_suite", "ts_library")

package(default_visibility = ["//visibility:public"])

# These are two separate files that provide the same tidy interface for running a performance
# benchmark.
#
# The testbed and protractor tests use different methods for measuring time. Since Karma does not
# patch console.time, the results are not pushed back from the page to the Karma server. Instead
# we use performance.now() to measure performance.

ts_library(
    name = "constants",
    srcs = [":constants.ts"],
)

ts_library(
    name = "protractor-benchmark-utilities",
    srcs = [":protractor-benchmark-utilities.ts"],
    deps = [
        ":constants",
        "@npm//@angular/dev-infra-private",
        "@npm//@types/node",
    ],
)

ts_library(
    name = "testbed-benchmark-utilities",
    srcs = [":testbed-benchmark-utilities.ts"],
    deps = [":constants"],
)

# ProtractorHarnessEnvironment

component_benchmark(
    name = "e2e_benchmark",
    driver = ":protractor.perf-spec.ts",
    driver_deps = [
        ":constants",
        ":protractor-benchmark-utilities",
        "@npm//protractor",
        "@npm//@types/jasmine",
        "@npm//@types/node",
        "//src/cdk/testing",
        "//src/material/button/testing",
        "//src/cdk/testing/protractor",
    ],
    ng_deps = [
        ":constants",
        "@npm//@angular/core",
        "@npm//@angular/platform-browser",
        "//src/material/button",
    ],
    ng_srcs = [":app.module.ts"],
    prefix = "",
    styles = ["//src/material/prebuilt-themes:indigo-pink"],
)

# TestbedHarnessEnvironment

ng_test_library(
    name = "unit_tests_lib",
    srcs = ["testbed.perf-spec.ts"],
    deps = [
        ":constants",
        ":testbed-benchmark-utilities",
        "//src/cdk/testing",
        "//src/cdk/testing/testbed",
        "//src/material/button",
        "//src/material/button/testing",
        "@npm//@angular/dev-infra-private",
    ],
)

ng_web_test_suite(
    name = "unit_benchmark_tests",
    deps = [":unit_tests_lib"],
)
